package com.xzj.admin.analysis.base.domain;

import com.alibaba.fastjson2.JSONObject;
import com.xzj.admin.analysis.base.util.AnalysisCommonUtil;
import lombok.Data;

import java.util.Date;

/**
 * 资源同步中间表
 *
 * @author xiazunjun
 * @date 2023/8/9 9:12
 */
@Data
public class ResMessageManage {
    /** 采集消息中间表ID */
    private String messageManageId;

    /** 消息唯一主键 */
    private String messageId;

    /** 消息来源 */
    private String messageSource;

    private String sourceId;

    /** 云资源id */
    private String cloudId;

    /** 区域 */
    private String standardCode;

    /** 资源池id */
    private String rmPoolId;

    /** json体数据存储 */
    private String messageJson;

    /** json对象计算的md5值 */
    private String messageJsonMd5;

    /** 关联cm_db生成的唯一键 */
    private String targetCreateId;

    /** 消息标识：add-edit-del-pushed */
    private String messageTag;

    /** 消息标识：add-edit-del-pushed */
    private Date messageTime;

    private JSONObject rowData;

    private String relateCacheKey;

    private String cloudType;

    private String suspendSync;

    /** 消息删除次数;消息删除次数 */
    private Integer messageDelNumber ;

    public static ResMessageManage create(JSONObject rowData, String cloudId) {
        ResMessageManage resMessageManage = new ResMessageManage();
        String rowDataStr = rowData.toJSONString();
        resMessageManage.setMessageJson(rowDataStr);
        String objMd5 = AnalysisCommonUtil.objectToMd5(rowDataStr);
        resMessageManage.setMessageJsonMd5(objMd5);
        resMessageManage.setRowData(rowData);
        resMessageManage.setCloudId(cloudId);
        return resMessageManage;
    }

}
